﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Register Src="../Shared/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<!DOCTYPE html>
<html>
<head runat="server">
    <uc1:Header ID="Header1" runat="server" />
    <style type="text/css">
        td.amrow
        {
            padding-right: 3px;
            padding-left: 3px;
            background: #f7f7f7;
            padding-bottom: 3px;
            padding-top: 3px;
        }
        a
        {
            color: #000000;
            text-decoration: none;
        }
        a:hover
        {
            color: #93B4E6;
            text-decoration: none;
        }
        .title
        {
            background-color: #99ABCC;
            color: White;
            font-weight: bold;
        }            
        .tabs
        {
            background: #E8F6FF;
        }
        
        .accordion .accordion-header
        {
            background: #ECF6FF;
        }
    </style>
    <script type="text/javascript">
        var tempTitle = "";
        function showTab(url, title) {
            var tab = $('#tab');
            if (tab.tabs('exists', title)) {
                tab.tabs('select', title);
                tempTitle = title;
            }
            else {
                if (tempTitle == "") {
                    tab.tabs('add', {
                        title: title,
                        content: "<iframe scrolling='yes' frameborder='0' src='/" + url + "' style='width:100%;height:100%;'/>",
                        closable: false
                    });
                } else {
                    var tempTab = tab.tabs("getTab", tempTitle);
                    tab.tabs("update", {
                        tab: tempTab,
                        options: {
                            title: title,
                            content: "<iframe scrolling='yes' frameborder='0' src='/" + url + "' style='width:100%;height:100%;'/>"
                        }
                    });
                }
                tempTitle = title;
            }

        }

        $(function () {
            $.ajax({
                type: 'POST',
                url: "/Home/LoadMenu/",
                dataType: "JSON",
                success: function (data) {
                    if (data.length > 0) {
                        $.each(data, function (index, domEle) {
                            if (domEle.lever.toString() == "1") {

                                var tempContent = "<table border='0' cellspacing='1' cellpadding='1' align='center'>";

                                $.each(data, function (i, d) {
                                    if ((d.lever == 2) && (d._parentId == domEle.id)) {
                                        var tempTr = "<tr><td height='23'><a href='#' onclick=\"showTab('" + d.url.substr(1) + "',$(this).html());\">" + d.name + "</a></td></tr>";
                                        tempContent = tempContent + tempTr;
                                    }
                                });

                                tempContent += "</table>";
                                $('#divAccordion').accordion('add', {
                                    title: domEle.name,
                                    content: tempContent,
                                    selected: false
                                });
                            }
                        });
                    }
                }
            });

            var nowDate = new Date();
            var now = nowDate.getFullYear() + "年" + (nowDate.getMonth() + 1) + "月" + nowDate.getDate() + "日 星期" + (nowDate.getDay())
            $("#spNow").text(now);

            showTab("Home/Default/", "首页");
        });

        function logout() {
            top.location = "/Home/Logout";
        }

        function modify() {
            $('#win').dialog({
                title: '修改密码',
                iconCls: 'icon-add',
                width: 380,
                height: 200,
                closed: false,
                cache: false,
                href: '/HospUser/ModifyPWD/',
                modal: true,
                buttons: [{
                    text: '提交',
                    iconCls: 'icon-ok',
                    handler: submit
                }, {
                    text: '取消',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        $('#win').dialog('close');
                    }
                }],
                onLoad: function () {

                }
            });
        }

        function submit() {
            $('#form').form('submit', {
                onSubmit: function () {
                    return $(this).form('validate');
                },
                success: function (msg) {
                    var msg1 = eval('(' + msg + ')');
                    if (msg1.IsSuccess) {
                        JSHelper.ShowInfo("保存成功", 'info', function () {
                                $('#win').dialog('close');
                        });
                    }
                    else {
                        JSHelper.ShowError(msg1.Message);
                    }
                },
                error: function () {
                    JSHelper.ShowError('保存失败！');
                }
            });
        }
    </script>
</head>
<body class="easyui-layout">
    <div data-options="region:'north',border:false" style="height: 95px;">
        <div data-options="region:'north',border:false" style="height: 70px; padding: 0;
            background: url(../Content/Images/log02.jpg) repeat-x left;">
            <div style="background: url(../Content/Images/log01.jpg) no-repeat left; width: 684px;
                height: 70px; display: block; float: left;">
            </div>
            <div style="background: url(../Content/Images/log03.jpg) no-repeat left; width: 276px;
                height: 70px; display: block; float: right;">
            </div>
        </div>
        <div data-options="region:'center',border:false" style="height: 25px; padding: 0;
            background: url(../Content/Images/bg1.jpg) repeat-x left;">
            <div style="padding-top: 6px; padding-left: 16px;float:left">
                欢迎&nbsp;<span style="color: Red; font-size: 15px;"><%=Session["username"]%></span>,
                <span id="spNow"></span>
            </div>
            <div style="padding-top: 1px;float:right;padding-right: 16px;">
                <img src="../Content/Icons/home.ico" onclick="showTab('home/Default/', '首页')" style="cursor:pointer;" border="0" width="24px" height="24px" alt="主页" title="主页" /> 
                <img src="../Content/Icons/modify.ico" onclick="modify()" style="cursor:pointer;" border="0" width="24px" height="24px" alt="修改密码" title="修改密码" />  
                <img src="../Content/Icons/logout.ico" onclick="logout()" style="cursor:pointer;" border="0" width="24px" height="24px" alt="退出" title="退出" />            
            </div>
        </div>
    </div>
    <div data-options="region:'west',split:true" border="true" style="width: 150px; border-right: 0;
        border-bottom: 0;">
        <div class="easyui-accordion" fit="true" border="true" id="divAccordion" style="background: #E8F6FF;">
        </div>
    </div>
    <%--    <div data-options="region:'east',split:true,collapsed:true,title:'留言板'" style="width: 100px;
        padding: 10px;">
        右边内容</div>
    <div data-options="region:'south',border:false" style="height: 30px; background: #A9FACD;
        padding: 10px;font-size:20px; font-weight:bolder; text-align:center;">
        底部版权信息</div>--%>
    <div data-options="region:'center'">
        <div id="tab" class="easyui-tabs" fit="true" border="false">
<%--            <div title="首页" style="padding: 20px; overflow: hidden;">
                
            </div>--%>
        </div>
    </div>
    <div id="win" />
</body>
</html>
